<template>
	<view class="">
		<view class="line"></view>
		<view class="yy-list" v-if="detailedAdrs == null">
			<view class="yy-address" @click.stop="toAddAddress()">
				<image class="address-icon" src="../../../static/sign.png" mode="widthFix"></image>
				<view class="add-address">手动添加收货地址</view>
			</view>
		</view>
		<view class="yy-list" v-else @click="addressOpen()">
			<view class="">
				<view class="detailedAddress">{{detailedAdrs.detailed_address}}，{{detailedAdrs.address_door}}</view>
				<view class="userAddress">{{detailedAdrs.address}}</view>
				<view class="userAddressInfo">{{detailedAdrs.name}}，{{detailedAdrs.phone}}</view>
			</view>
			<view class="">
				<image class="to-right" src="../../../static/right.png" mode="widthFix"></image>
			</view>
		</view>
		<!-- 地址选择弹窗 -->
		<uni-popup ref="popup" type="bottom">
			<view class="dars-box">
				<view class="dars-title">选择收货地址</view>
				<view class="dars-item" v-for="(item,index) in userAddress" :key="index" @click="adrsItem(item)">
					<view class="popDelAddress">{{item.detailed_address}}，{{item.address_door}}</view>
					<view class="popUserAddress">{{item.address}}</view>
					<view class="popUserAddressInfo">{{item.name}}，{{item.phone}}</view>
				</view>

			</view>
		</uni-popup>

		<view class="yy-list">
			<view class="yy-title">已选衣物</view>
			<view class="yy-right yy-text">{{orderInfo.title}}</view>
		</view>

		<!-- <view class="yy-list" @click="time = true">
			<view class="yy-title">预约时间</view>
			<view class="yy-right">
				<view class="yy-time-title" v-if="subscribe_time == ''">请选择</view>
				<view class="yy-time-title color-black" v-else>{{subscribe_time}}</view>
				<image class="arrow-img" src="../../../static/right.png" mode="widthFix"></image>
			</view>
		</view> -->

		<!-- <view class="yy-list">
			<view class="yy-title">是否上门收送</view>
			<view class="yy-right">
				
				<radio-group @change="isDelivery" style="transform: scale(0.8);color: #A8A8A8;">
					<label>
						<radio value="0" color="#FF723B" />不配送
					</label>
					<label>
						<radio value="1" color="#FF723B" style="margin-left: 25rpx;" />配送
					</label>
				</radio-group>

			</view>
		</view> -->

		<!-- <view class="yy-list" @click="isUse" v-if="orderInfo.free_num > 0">
			<view class="yy-title">床品免费预约({{orderInfo.free_num}}次)</view>
			<view class="yy-right">
				<text class="yy-text">是否使用</text>
				<radio :checked="is_free_wish" style="transform: scale(0.8);" color="#FF723B"></radio>
			</view>
		</view>
		<view class="yy-tip" v-if="orderInfo.free_num > 0">提示：会员卡支付才能免费预约哦！不可和其他衣物一起使用</view>
		<view class="line"></view> -->

		<!-- 备注 -->
		<!-- <view class="yy-remark">
			<input type="text" maxlength="20" v-model="desc" placeholder-style="color: #A8A8A8"
				placeholder="备注(选填)，请输入您的其他要求，最多20字" />
		</view> -->
		<view class="line"></view>

		<!-- 支付方式 -->
		<view class="yy-pay">
			<view class="yy-pay-title">支付方式</view>
			<view class="yy-pay-boxs" v-for="(it, i) in payArr" :key="i" @click="payClick(it.pay_type)">
				<view class="yy-pay-left">
					<!-- <text class="iconfont weixin-icon" v-if="it.pay_type == 1">&#xe6ea;</text> -->
					<text class="iconfont card-icon" v-if="it.pay_type == 4 ">&#xe611;</text>
					<text class="iconfont yue-icon" v-if="it.pay_type == 3">&#xe66e;</text>
					<view  class="yy-pay-money">
						{{it.title}}
						<text v-if="it.pay_type == 4">({{user_card.length}}张) </text>  
														<!-- 会员卡可洗件数{{frequenceCount}} -->
						<text v-if="it.pay_type == 3">(可用余额: ￥{{orderInfo.user_money}})</text>
					</view>
				</view>
				<radio  :checked="it.pay_type == pay_type" color="#FF723B"></radio>
			</view>
		</view>

		<view class="buts" @click="submit" v-if="orderInfo.is_member">会员免费预约</view>
		<!-- <view class="buts" @click="submit" v-if="!orderInfo.is_member || pay_type != 4"> -->
		<!-- {{orderInfo.is_discount ? ((totalPrice*(orderInfo.discount)).toFixed(2)) : (totalPrice.toFixed(2))}}元/确认支付 -->
		<!-- {{orderInfo.is_discount ? ((totalPrice*(orderInfo.discount/10)+freight).toFixed(2)) : (totalPrice.toFixed(2)+freight)}}元/确认支付 -->
		<!-- <text style="color: #fbff00;">{{orderInfo.discount == 10 && orderInfo.is_discount ? '' : '（'+orderInfo.discount + '折优惠）'}}</text> -->
		<!-- </view> -->

		<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
		<view class="but_uprop" v-if="!orderInfo.is_member || pay_type != 4">
			<view class="but_left">
				<view class="top_box">
					<view class="totle_pirce">
						￥{{totalPrice.toFixed(2)}}
						<!-- ￥{{orderInfo.is_discount ? ((totalPrice*(orderInfo.discount/10)+freight).toFixed(2)) : (totalPrice.toFixed(2)+freight)}} -->
					</view>
					<!-- <text class="youhui">
						{{orderInfo.discount == 10 && orderInfo.is_discount ? '' : '（'+orderInfo.discount + '折优惠）'}}
					</text> -->
				</view>
				<!-- <view class="btm_box">加配送费￥{{freight}}</view> -->
			</view>
			<view class="but_right" @click="submit">提交订单</view>
		</view>
		
		<u-picker v-model="time" mode="time" :params="params" @confirm="confirms"></u-picker>

		<!-- 余额不足弹窗 -->
		<u-popup v-model="popup" mode="center" border-radius="20" width="568rpx" height="400rpx" close-icon="close"
			closeable>
			<view class="pop-title">提示</view>
			<view class="pop-cont">{{pop_title}}</view>
			<view v-if="special == true" class="pop-btn" @click="closepop">取消</view>
			<view v-else class="pop-btn" @click="chongzhi">去充值</view>
		</u-popup>

		<u-popup v-model="show" mode="center">
			<view v-for="cardinfo in user_card" :key="cardinfo.id" class="usercard" @click="cardxiyi(cardinfo.id)">
				<view class="imgs">
					<image class="user-img" :style="{color: vipColor[cardinfo.id-1].color}" :src="base_domian + cardinfo.card.img"></image>
					<view class="user-name">{{cardinfo.card.name}}</view>
					<view class="user-time">服务截至时间: &nbsp; {{cardinfo.end_text}}</view>
					<view class="user-frequence">已洗衣物:{{cardinfo.clothes ? cardinfo.clothes : 0}}</view>
					<view v-if="cardinfo.card.bed_num" class="user-bed">已洗床品:{{cardinfo.beds ? cardinfo.beds : 0}}</view>
				</view>
				
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				base_domian : this.baseDomian,
				vipColor: [
					{
						imgUrl: 'https://syxiyi.oss-cn-shenzhen.aliyuncs.com/frontend/img/yuekabg.png',
						color: '#FF9344'
					},
					{
						imgUrl: 'https://syxiyi.oss-cn-shenzhen.aliyuncs.com/frontend/img/yuekabg.png',
						color: '#FF9344'
					},
					{
						imgUrl: 'https://syxiyi.oss-cn-shenzhen.aliyuncs.com/frontend/img/studykabg.png',
						color: '#1C0000'
					},
					{
						imgUrl: 'https://syxiyi.oss-cn-shenzhen.aliyuncs.com/frontend/img/year_card.png',
						color: '#B58262'
					}
				],
				show:false,
				userAddress: [], //获取用户收货地址
				time: false,
				popup: false,
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: false
				},
				subscribe_time: '', // 预约时间
				desc: '', // 备注
				value: 0,
				store_id: '', // 门店id
				car_ids: '', // 购物车ids
				orderInfo: '', // 预下单信息
				type: 1, // 类型，1：预约订单，5为充值订单，6为会员卡订单
				order_type: 1, // 订单类型，1为预约订单，5为充值订单，6会员卡订单
				pay_type: 3, // 支付方式，1：微信支付，3为余额支付 , 4为会员卡支付
				freight: 0, //运费/配送费
				totalPrice: 0, //总金额
				totalNum: 0,
				pop_url: '',
				pop_title: '',
				userinfo: [],
				payArr: [
					// {
					// 	title: '微信支付',
					// 	pay_type: 1
					// },
					{
						title: '会员卡支付',
						pay_type: 4
					},
					{
						title: '余额现金',
						pay_type: 3
					},
				],
				dadad: '',
				is_delivery: 0, //是否配送，默认null
				is_free_wish: false,
				detailed_address: '', //详细地址
				detailedAdrs: [], // 默认地址
				user_card:[], // 会员卡的信息
				frequenceCount:0,// 总共洗衣次数
				xiyicount:0,// 要洗衣的件数
				bedcount:0,
				xiyiinfo:[],
				cardid:0,// 选择的会员卡id
				special:false
			}
		},
		onLoad(options) {
			this.getUserInfo()
			// this.store_id = uni.getStorageSync('store_id')
			this.store_id = options.store_id
			// console.log('店铺id=' + this.store_id)
			this.car_ids = options.ids
			this.preOrder()

			
		},
		onShow() {
			this.novip()
			this.popup = false
			this.getUserAddress()
			this.getDetailedAdrs()
		},
		methods: {
			closepop(){
				this.popup = false
			},
			novip(){
				let that = this
				this.$ajaxRequest.post(this.baseUrl + 'shop/order/confim', {
					car_ids: this.car_ids,
					store_id: this.store_id,
					type: 1
				}, true).then(res => {
					// console.log(res.data.data.data,'zhoufnimune');
					if(res.data.data.data[0].cate_id == 75)
					{
						that.special = true
						that.payArr = [
										{
											title: '微信支付',
											pay_type: 1
										},
										{
											title: '会员卡支付',
											pay_type: 4
										},
										{
											title: '余额现金',
											pay_type: 3
										},
									]
					
					}
				})
			},
			// 获取会员卡信息的方法
			userCard(){
				this.$ajaxRequest.get(this.baseUrl + 'shop/order/usercard', {
					uid: uni.getStorageSync('UserInfo').id,
					store_id:uni.getStorageSync('store_id')
				}, true).then(res => {
					if (res.data.code == 200) {
						console.log('返回的会员卡数据', res.data);
						this.user_card=res.data.data
						
						console.log(this.user_card,'赋值的数据');
						this.user_card.forEach(item => {
							this.frequenceCount+=item.frequence
						});
						// console.log(this.frequenceCount,'总共洗衣的次数');
						// console.log(this.orderInfo.data,'这是洗衣的信息6666');
						this.orderInfo.data.forEach(item => {
							if(item.num)
							{
								this.xiyicount+=item.num
							}else{
								this.bedcount+=item.bed_num
							}
						});

						// console.log(this.xiyicount,'总共需要洗衣的次数');

					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},

			//获取用户收货地址
			getUserAddress() {
				this.$ajaxRequest.get(this.baseUrl + 'shop/Member/UserAddress', {
					uid: uni.getStorageSync('UserInfo').id
				}, true).then(res => {
					if (res.data.code == 200) {
						console.log('this.获取用户收货地址', res.data.data);
						this.userAddress = res.data.data
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},
			//用户的默认地址
			getDetailedAdrs() {
				this.$ajaxRequest.get(this.baseUrl + 'shop/Member/DetailedAdrs', {
					uid: uni.getStorageSync('UserInfo').id
				}, true).then(res => {
					console.log('用户的默认地址', res.data.data);
					this.detailedAdrs = res.data.data
				})
			},

			//跳转手动添加收货地址
			toAddAddress() {
				uni.navigateTo({
					url: '/pages/yuyue/lijiyuyue/address'
				})
			},

			// 获取用户信息（判断是否是VIP会员）
			getUserInfo() {
				this.$ajaxRequest.get(this.baseUrl + 'user/info', {
					store_id: this.store_id
				}, true).then(res => {
					console.log(res)
					if (res.data.code == 200) {
						this.userinfo = res.data.data
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},

			//获取店铺数据
			getStoreInfo() {
				this.$ajaxRequest.get(this.baseUrl + 'shop/index/storeInfo', {
					sid: this.store_id
				}, true).then(res => {
					if (res.data.code == 200) {
						this.freight = parseFloat(res.data.data.freight) //字符串转浮点数运算
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},

			//打开地址选择弹窗
			addressOpen() {
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open('top')
			},
			//关闭地址选择弹窗
			addressClose() {
				this.$refs.popup.close()
			},
			//点击选择弹窗地址
			adrsItem(item) {
				this.addressClose()
				this.detailedAdrs = item
			},
			// 选择是否配送
			isDelivery(e) {
				this.is_delivery = e.detail.value
				if (this.is_delivery == 1) {
					this.getStoreInfo()
				} else {
					this.freight = 0
				}
			},
			isUse() {
				this.is_free_wish = !this.is_free_wish
				if (this.is_free_wish) {
					this.payArr = [{
						title: '会员卡支付',
						pay_type: 4
					}]
					this.pay_type = 4
				} else {
					this.payArr = [{
							title: '微信支付',
							pay_type: 1
						},
						{
							title: '会员卡支付',
							pay_type: 4
						},
						{
							title: '余额现金',
							pay_type: 3
						},
					]
				}
				this.$forceUpdate()
			},
			payClick(i) {
				let that = this
				console.log(i,'选择的支付方式');

				this.pay_type = i
				if (i == 4) { // 会员卡
				// console.log(6666);
					if(this.frequenceCount<this.xiyicount || this.user_card[0].bed_num<this.bedcount)
					{
						that.popup = true
						that.pop_title = '会员卡可洗件数不足'
						that.pop_url = '/pages/vip/index'
					}if(this.frequenceCount>=this.xiyicount && this.user_card[0].bed_num>=this.bedcount && this.special == false){
						that.show = true
						uni.showToast({
							title:'请选择会员卡',
							icon:'none',
						})
					}

					if(that.special == true)
					{
						that.popup = true
						that.pop_title = '此类商品不支持会员卡支付'
					}
					
					
				}
				if (i == 3 && this.totalPrice > this.orderInfo.user_money) { // 余额
					this.popup = true
					this.pop_title = '余额不足'
					this.pop_url = '/pages/user/wallet/chongzhi/index'
				}
			},
			preOrder() {
				let that = this
				this.$ajaxRequest.post(this.baseUrl + 'shop/order/confim', {
					car_ids: this.car_ids,
					store_id: this.store_id,
					type: 1
				}, true).then(res => {
					if (res.data.code == 200) {
						this.orderInfo = res.data.data
						// console.log(this.orderInfo,'this.orderInfo的信息');
						if(this.orderInfo){
							this.userCard()
						}
						// this.xiyiinfo=this.orderInfo
						this.orderInfo.data.filter(it => {
							console.log(it,'xienimazhouf');
							// 判断是否是会员价
							if (this.userinfo.lid == 1 || this.userinfo.lid == 2 || this.userinfo.lid ==
								3) {
									if(it.num)
									{
										that.totalPrice += it.num * parseFloat(it.vip_price)
										that.totalPrice += it.bed_num * parseFloat(it.vip_price)
									}else{
										that.totalPrice += it.num * parseFloat(it.vip_price)
										that.totalPrice += it.bed_num * parseFloat(it.vip_price)
									}
							} else {
								this.totalPrice += it.num * parseFloat(it.price)
								that.totalPrice += it.bed_num * parseFloat(it.vip_price)
							}
							this.totalNum += it.num
						})
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
				
				// this.$nextTick(this.userCard());
				
			},
			confirms(e) {
				console.log(e)
				this.subscribe_time = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute
			},
			chongzhi() {
				uni.navigateTo({
					url: this.pop_url
				})
			},
			submit() {
				if(this.pay_type==1){
					if(this.detailedAdrs == null)
					{
						console.log('noaddress');
						uni.showToast({
										title:'请填写收货地址',
										icon:'error'
									})
						return false
					}
					console.log(this.store_id)
					// if (!this.subscribe_time) {
					// 	uni.showToast({
					// 		title: '请选择预约时间',
					// 		icon: 'none'
					// 	})
					// } else 
					if (this.is_delivery == null) {
						uni.showToast({
							title: '请选择是否配送',
							icon: 'none'
						})
					}
					else{
						this.$ajaxRequest.post(this.baseUrl + 'shop/order/info', {
						car_ids: this.car_ids,
						store_id: this.store_id,
						type: this.type,
						order_type: this.order_type,
						pay_type: this.pay_type,
						// subscribe_time: this.subscribe_time,
						subscribe_time: '3000-01-01 00:00',
						desc: this.desc,
						freight_price: this.freight, //运费
						is_free_wish: this.is_free_wish,
						name: this.detailedAdrs.name, //姓名
						phone: this.detailedAdrs.phone, //电话号码
						latitude: this.detailedAdrs.latitude, //纬度
						longitude: this.detailedAdrs.longitude, //经度
						user_address: this.detailedAdrs.address, //地址
						detailed_address: this.detailedAdrs.detailed_address, //详细地址
						address_door: this.detailedAdrs.address_door, //门牌号
						is_delivery: this.is_delivery,
						total_price:this.totalPrice
						}, false)
						.then(res => {
							console.log(res)
							this.$ajaxRequest.post(this.baseUrl + 'shop/order/pay', {
								order_id: res.data.data.order_id,
								pay_type: this.pay_type,
							}, true).then(result => {
								console.log(result, '支付')
								if (result.data.code == 201 || result.data.code == 200) {
									console.log('pay_type =' + this.pay_type)
									if (this.pay_type == 1) { // 微信支付
										uni.getProvider({
											service: 'payment',
											success: function(payRes) {
												if (~payRes.provider.indexOf('wxpay')) {
													uni.requestPayment({
														provider: 'wxpay',
														timeStamp: result.data.data.timeStamp,
														nonceStr: result.data.data.nonceStr,
														package: result.data.data.package,
														signType: result.data.data.signType,
														paySign: result.data.data.paySign,
														success: function(res) {
															console.log('success:' + res);
															
															uni.navigateTo({
																url: '/pages/order/paysuccess/index'
															})
														},
														fail: function(err) {
															console.log(err);
															uni.showToast({
																title: '支付失败',
																icon: 'none'
															})
															setTimeout(() => {
																uni.navigateBack({
																	delta: 1
																})
															}, 700);
															
														}
													});
												}
											}
										});
									} else { // 余额支付
										uni.showToast({
											title: '支付成功',
											icon: 'none'
										})
										uni.navigateBack({
											delta: 1
										})
									}
								} else {
									uni.showToast({
										title: result.data.msg,
										icon: 'none'
									})
								}
							})
								
							

						})

						return
					}
				}
				// 余额支付
				if(this.pay_type==3){
					console.log('我是余额支付666');
					let self = this
					if(this.detailedAdrs == null)
					{
						console.log('noaddress');
						uni.showToast({
										title:'请填写收货地址',
										icon:'error'
									})
						return false
					}
					console.log(this.store_id)
					// if (!this.subscribe_time) {
					// 	uni.showToast({
					// 		title: '请选择预约时间',
					// 		icon: 'none'
					// 	})
					// } else 
					if (this.is_delivery == null) {
						uni.showToast({
							title: '请选择是否配送',
							icon: 'none'
						})
					} 
					// else if (this.frequenceCount<this.xiyicount && this.pay_type == 4) {
					// 	this.popup = true
					// 	this.pop_title = '会员卡可洗件数不足'
					// 	this.pop_url = '/pages/vip/index'
					// }
					else if (this.totalPrice > this.orderInfo.user_money && this.pay_type == 3) {
						this.popup = true
						this.pop_title = '余额不足'
						this.pop_url = '/pages/user/wallet/chongzhi/index'
					// } else if (!this.orderInfo.has_subscribe) {
					// 	uni.navigateTo({
					// 		url: '/pages/yuyue/lijiyuyue/index'
					// 	})
					} else {
						uni.showModal({
							title: '确认预约',
							content: '',
							success(res) {
								console.log(res)
								if (res.confirm) {
									self.payments()
								} else {
									uni.showToast({
										title: '取消预约',
										icon: 'none'
									})
								}
							}
						})
					}
				}

				// 会员卡支付
				if(this.pay_type==4){
					
					if(this.cid==0){
						uni.showToast({
							title: '请选择会员卡支付',
							icon: 'none'
						})
						return false
					}
					let self = this
					if(this.detailedAdrs == null)
					{
						console.log('noaddress');
						uni.showToast({
										title:'请填写收货地址',
										icon:'error'
									})
						return false
					}
					console.log(this.store_id)
					// if (!this.subscribe_time) {
					// 	uni.showToast({
					// 		title: '请选择预约时间',
					// 		icon: 'none'
					// 	})
					// } else 
					if (this.is_delivery == null) {
						uni.showToast({
							title: '请选择是否配送',
							icon: 'none'
						})
					}else{

					// var data={
					// 	uid: uni.getStorageSync('UserInfo').id, // 用户id
					// 	freight_price: this.freight, //运费
					// 	name: this.detailedAdrs.name, //姓名
					// 	phone: this.detailedAdrs.phone, //电话号码
					// 	pay_type:4, // 支付方式
					// 	user_address: this.detailedAdrs.address, //地址
					// 	detailed_address: this.detailedAdrs.address_door, // 详细地址
					// 	is_delivery: this.is_delivery, // 是否配送
					// 	store_id:this.store_id, // 门店id
					// 	// detailed_address: this.detailedAdrs.detailed_address, //详细地址
					// 	// address_door: this.detailedAdrs.address_door, //门牌号
					// }

					let self = this
					uni.showModal({
						title:'确认预约',
						content:'',
						success(res){
							if(res.confirm)
							{
								self.$ajaxRequest.post(self.baseUrl + 'shop/order/card',{
									uid: uni.getStorageSync('UserInfo').id, // 用户id
									freight_price: self.freight, //运费
									name: self.detailedAdrs.name, //姓名
									phone: self.detailedAdrs.phone, //电话号码
									pay_type:4, // 支付方式
									user_address: self.detailedAdrs.address, //地址
									detailed_address: self.detailedAdrs.detailed_address, //详细地址
									address_door: self.detailedAdrs.address_door, //门牌号
									is_delivery: self.is_delivery, // 是否配送
									store_id:self.store_id, // 门店id
									frequence:self.xiyicount, // 要洗衣服的件数
									bednum:self.bedcount,//床品件数
									cardid:self.cardid, // 选择会员卡的id
									title:self.orderInfo.title, // 订单标题
									desc:self.desc, // 订单备注
									buy_num:self.xiyicount,
									bed_num:self.bedcount,
									member_id:self.cardid,
								},false).then(res=>{
									if(res.data.code==200){
										// console.log(res.data);
										// self.payments()
										console.log(
											'success:' +
											res);
										uni.showToast({
											title: '支付成功',
											icon: 'none'
										})
										uni.redirectTo({
											url: '/pages/order/paysuccess/index'
										})
									}else{
										uni.showToast({
											title: res.data.msg,
											icon: 'none'
										})
									}
								})
							}
						}
					})
				}


				}
				


			},
			payments() {
				this.$ajaxRequest.post(this.baseUrl + 'shop/order/info', {
					car_ids: this.car_ids,
					store_id: this.store_id,
					type: this.type,
					order_type: this.order_type,
					pay_type: this.pay_type,
					// subscribe_time: this.subscribe_time,
					subscribe_time: '3000-01-01 00:00',
					desc: this.desc,
					freight_price: this.freight, //运费
					is_free_wish: this.is_free_wish,
					name: this.detailedAdrs.name, //姓名
					phone: this.detailedAdrs.phone, //电话号码
					latitude: this.detailedAdrs.latitude, //纬度
					longitude: this.detailedAdrs.longitude, //经度
					user_address: this.detailedAdrs.address, //地址
					detailed_address: this.detailedAdrs.detailed_address, //详细地址
					address_door: this.detailedAdrs.address_door, //门牌号
					is_delivery: this.is_delivery
				}, false).then(res => {
					console.log("预约成功", res)
					if (res.data.code == 200) {
						// 会员卡支付
						if (this.pay_type == 4) {
							console.log('会员卡支付')
							uni.showToast({
								title: '预约成功',
								icon: 'none'
							})
							setTimeout(() => {
								uni.redirectTo({
									url: '/pages/order/paysuccess/index'
								})
							}, 500)
						} else {
							console.log('非会员卡')
							this.$ajaxRequest.post(this.baseUrl + 'shop/order/pay', {
								order_id: res.data.data.order_id,
								pay_type: this.pay_type
							}, true).then(result => {
								if (result.data.code == 201 || result.data.code == 200) {
									if (this.pay_type == 1) { // 微信支付
										console.log('微信支付', result)
										uni.getProvider({
											service: 'payment',
											success: function(payRes) {
												if (~payRes.provider.indexOf('wxpay')) {
													uni.requestPayment({
														provider: 'wxpay',
														timeStamp: result.data.data
															.timeStamp,
														nonceStr: result.data.data
															.nonceStr,
														package: result.data.data
															.package,
														signType: result.data.data
															.signType,
														paySign: result.data.data
															.paySign,
														success: function(res) {
															console.log(
																'success:' +
																res);
															uni.showToast({
																title: '支付成功',
																icon: 'none'
															})
															uni.redirectTo({
																url: '/pages/order/paysuccess/index'
															})
														},
														fail: function(err) {
															console.log(err);
															uni.showToast({
																title: '支付失败',
																icon: 'none'
															})
															uni.navigateBack({
																delta: 1
															})
														}
													});
												}
											}
										});
									} else if (this.pay_type == 3) { // 余额支付
										console.log('余额支付')
										uni.redirectTo({
											url: '/pages/order/paysuccess/index'
										})

									}
								}

							})
						}
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},

			// 选择不同的会员卡
			cardxiyi(id){
				// console.log(id,'选择会员卡的id');
				uni.showToast({
					title:'选择会员卡成功',
					icon:'success',
				})
				this.cardid=id
				this.show=false
			}
		}
	}
</script>

<style lang="scss">
	.imgs{
		width: 320px;
		height: 150px;
		position: relative;
		margin: 7px 2px;
		overflow: hidden;

		.user-name{
			position: absolute;
			z-index: 3;
			top: 10px;
			left: 50%;
			transform: translateX(-50%);
			font-size: 20px;
			color: white;
		}

		.user-time{
			position: absolute;
			font-size: 15px;
			z-index: 3;
			top: 57px;
			margin-left: 15px;
		}

		.user-frequence{
			position: absolute;
			z-index: 3;
			font-size: 15px;
			top: 90px;
			margin-left: 15px;
		}

		.user-bed{
			position: absolute;
			z-index: 3;
			font-size: 15px;
			top: 90px;
			margin-left: 150px;
		}
	}
	.user-img{
		width: 100%;
		
	}
	.usercard{
		margin-top: -10rpx;
	}
	.yy-tip {
		font-size: 28rpx;
		color: #FF723B;
		padding-left: 30rpx;
		padding-bottom: 20rpx;
		/* background: #FAFAFA; */
	}

	.line {
		width: 100%;
		height: 20rpx;
		background: #FAFAFA;
	}

	//选择地址弹窗
	.dars-box {
		width: 100%;
		height: 820rpx;
		background-color: #fff;

		.dars-title {
			display: flex;
			justify-content: center;
			align-items: center;
			padding-top: 22rpx;
			font-size: 32rpx;
			font-weight: bold;
		}

		.dars-item {
			padding: 30rpx 30rpx;
			border-bottom: 1rpx solid #FAFAFA;

			.popDelAddress {
				font-size: 32rpx;
				font-weight: bold;
			}

			.popUserAddress {}

			.popUserAddressInfo {
				color: #999;
			}
		}
	}

	.yy-list {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 30rpx;
		border-bottom: 1rpx solid rgba(168, 168, 168, 0.15);
	}

	.detailedAddress {
		font-size: 32rpx;
		font-weight: bold;
	}

	.userAddress {}

	.userAddressInfo {
		color: #999;
	}

	.to-right {
		width: 20rpx;
	}

	.yy-address {
		display: flex;
		align-items: center;

		.address-icon {
			width: 50rpx;
		}

		.add-address {
			color: #999;
			margin-left: 20rpx;
		}
	}

	.yy-address-title {
		width: 20%;
	}

	.yy-address-context {
		width: 80%;
	}

	.yy-list:last-child {
		border: 0;
	}

	.yy-title {
		font-size: 30rpx;
		color: #323232;
	}

	.arrow-img {
		width: 20rpx;
	}

	.yy-right {
		display: flex;
		align-items: center;
	}

	.yy-text {
		max-width: 500rpx;
		color: #A8A8A8;
		font-size: 28rpx;
	}

	.yy-time-title {
		font-size: 30rpx;
		color: #A8A8A8;
		padding-right: 20rpx;
	}

	.color-black {
		color: #323232;
	}

	.yy-input {
		text-align: right;
		padding-right: 20rpx;
		font-size: 30rpx;
	}

	.yy-remark {
		padding: 30rpx;
	}

	.yy-remark>input {
		font-size: 30rpx;
		width: 100%;
	}

	/* 支付方式 */
	.yy-pay-title {
		padding: 40rpx 30rpx;
		font-size: 36rpx;
		color: #323232;
		font-weight: 700;
	}

	.yy-pay-boxs {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 30rpx;
	}

	.yy-pay-left {
		display: flex;
		align-items: center;
	}

	.yy-pay-img {
		display: flex;
	}

	.yy-pay-img>image {
		width: 38rpx;
		height: 36rpx;
	}

	.yy-pay-money {
		padding-left: 23rpx;
		font-size: 30rpx;
		color: #323232;
	}

	.yy-pay-money>text {
		font-size: 24rpx;
		color: #A8A8A8;
		padding-left: 10rpx;
	}

	/* 按钮 */
	.but_uprop {
		margin-left: 30rpx;
		border-radius: 45rpx;
		border: 1rpx solid rgba(128, 128, 128, .2);
		width: 690rpx;
		position: fixed;
		bottom: 38rpx;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		background: #fff;

		.but_left {
			.top_box{
				display: flex;
				.totle_pirce{
					padding-right: 20rpx;color: #FF8941;
					font-size: 32rpx;
					font-weight: bold;
				}
				.youhui{
					color: #FF8941;
				}
			}
			.btm_box{
				color: #999;
				text-align: right;
				padding-right: 90rpx;
			}
		}

		.but_right {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 238rpx;
			height: 100rpx;
			background: linear-gradient(-17deg, rgba(255, 114, 59, 1), rgba(255, 147, 68, 1));
			border-radius: 0px 45rpx 45rpx 0px;
			text-align: center;
			color: white;
			line-height: 100rpx;
			.tijiao-but {
				
			}
		}
	}


	// ======
	.buts {
		position: fixed;
		bottom: 50rpx;
		left: 50%;
		transform: translateX(-50%);
		width: 688rpx;
		height: 90rpx;
		background: linear-gradient(-17deg, rgba(255, 114, 59, 1), rgba(255, 147, 68, 1));
		border-radius: 45rpx;
		text-align: center;
		line-height: 90rpx;
		color: #fff;
		font-size: 30rpx;
	}

	.pop-title {
		padding: 34rpx 0;
		text-align: center;
		font-size: 36rpx;
		color: #323232;
		font-weight: 700;
		border-bottom: 1rpx solid rgba(168, 168, 168, 0.15);
	}

	.pop-cont {
		font-size: 30rpx;
		color: #FF723B;
		text-align: center;
		padding: 50rpx 0;
	}

	.pop-btn {
		width: 508rpx;
		height: 90rpx;
		background: linear-gradient(-17deg, rgba(255, 114, 59, 1), rgba(255, 147, 68, 1));
		border-radius: 45rpx;
		text-align: center;
		line-height: 90rpx;
		color: #fff;
		font-size: 30rpx;
		margin: auto;
	}

	@font-face {
		font-family: 'iconfont';
		src: url('data:application/font-woff2;charset=utf-8;base64,d09GMgABAAAAAAQ0AA0AAAAACKwAAAPfAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGh4GVgCCUhEICoRwhBoLDgABNgIkAxQEIAWFCAdIG2EHUZQvSpjsY/XlHEWS3IyH//b73z4zc+WbJk0mobvhVaxkFglCJlG6h0IimZTwfnhPe0nGZEZvotuJbQegGcGD9UX9yYpL9Su+P8h+jb1agC618U9Egq1QOBiBBhaqjWLV/sEDFExUg5SBeU5OkKJxnIWAz9OqXIAv5Xmz3LUR9GIcSEJWCQUJUSBeATvpBXodwEvg9fEfDIILJFUGbuLpfecEsPsl+OYDxvrPggiGAQdBADIyJiDgECYwgc060Golfgm+SX/z4f9/UGolf0j2SkoDAvKIGgRvIgHJzxOA/xCd/4CCGvSiF58AYhgAFABkWT0zE8d5ePQFcFwE5y5h9c9P43yNu4uDCEbeI/ib7gDgjbdhQHLggCAgiueaZfDRBeUZyRByqWmBNd+4iBQ8eEC9fz/o0aPghw9DHz6ksT4LEQ7QmmZY/WI4DN+XQ/BZOXKOIBDarNSQKkEbHFvakaQGD80pz4xIBBE9PaxukSAoCVm8Z0qlPXoUN7uYQhTQDFWJxdAZAp4dFHyBIFbDm06wjivNniRPBfF+gyss9QyFTjE/Ce0L8dS9EnqprKC0r6SgXPlE+ZgSV2emusKTNTJ2S+NRs4egvbjHa48LQvXK9UoNyg1C0PIy2ihrF7IhmyZlo3bi+Dm0FW07fpY/AOu5eqEf68NAAmWs++pFMhDkjls0Xn75b7fjjfEI0DSKPyMgwMMXT4mDMzIypz2c8ieQe1ztPk3UZtYLNS6E9C33vP2H8u92HMiDHSKCpq+0kgiJAATl0DT8bPTO4xgDCU97Fc+MkbSYQ90j3SVxEe++nADkCa/lsKKz4z0oP4VxVFmFjKA3VzAS/G/VeqvIheeZ2ljjkU3XpKlm1PFtmqn/y4p1duC7TUXN6AAQCM7evH8ZzW/1m4tgg3bgMOg8Z4O8AKCVQFB3RykApSZJpfilBxSOxACB2gEOkNCtGx0Qw14Ckh+jpSG0LpE0niFrPWeL+BqVHm9Ra31Ft6VwWN5jJHoBE4UbWAQAwiAHJP3uIRuUxxaxHZVxS6gNuoVu1z5M7zEb6YDbkI0uVq6gT0ARp8iaJF6GdIw+uXC6tyb8XYT/CfvOECgNzssBztEx5UkVKxs8QNeu//Yp6zW6bDmSKin06dADU9fe9XX0wrI7xPjDN63mJTnyMRnIlYuBgiFbhjQULnF8gi5VqgwUmbJlSEYXL5cO2PcozMlnGuTmMia7/iO+/jFn+DFkG+Bh8sQNZ0GXLkbCto74LFMwF0kxQvs780g/0Y1u7P01QgoUwRA2jqyk2LjYDKIoKZ35Xx9jivLoHAX0pMKkdAA=') format('woff2');
		font-weight: normal;
		font-style: normal;
		font-display: swap;
	}

	.iconfont {
		font-family: "iconfont" !important;
		font-size: 40rpx;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	.icon-qiabao:before {
		content: "\e611";
	}

	.icon-yingshouyue:before {
		content: "\e66e";
	}

	.icon-weixin:before {
		content: "\e6ea";
	}

	.weixin-icon {
		color: #4FB674;
	}

	.card-icon {
		color: #405EDD;
	}

	.yue-icon {
		color: #FF723B;
	}
</style>
